<?php
/**
 * @version $Id: install.unocloud.php 2 2010-05-25 10:13:33Z vladzimirs $
 * @package UnoCloud
 * @copyright Авторские права (C) 2009-2010 UnoCloud team & (C) 2007-2010 Joostina team &. Все права защищены.
 * @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
 * UnoCart! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
 * Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл help/copyright.php.
 */


defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');

function com_install()
{
    global $database, $mainframe;


?>
 <div style="text-align:left;">
  <table width="100%" border="0">

<?php

    $UNOCLOUD_upgrades = array();

    $UNOCLOUD_upgrades[0]['test'] = "SELECT `type` FROM #__unocloud_stat";
    $UNOCLOUD_upgrades[0]['updates'][0] =
        "ALTER TABLE `#__unocloud_stat` ADD `type` INT NOT NULL DEFAULT '0'," .
        "CHANGE `word` `word` VARCHAR( 200 )";
    $UNOCLOUD_upgrades[0]['updates'][1] = "UPDATE `#__unocloud_stat` SET type='1'";

    $UNOCLOUD_upgrades[0]['info'] = "1.0.x to 2.0.1 ";

    echo ("<br>Databse upgrade:<br>");
    foreach ($UNOCLOUD_upgrades as $UNOCLOUD_upgrade) {
        $database->setQuery($UNOCLOUD_upgrade['test']);
        if (!$database->query()) {
            foreach ($UNOCLOUD_upgrade['updates'] as $UNOCLOUD_sql) {
                $database->setQuery($UNOCLOUD_sql);
                if (!$database->query()) {
                    echo ("<br><font color=red>" . $UNOCLOUD_upgrade['info'] . " failed! SQL error:" .
                        $database->stderr(true) . "</font><br />");
                }
            }
            echo "<br><font color=green>" . $UNOCLOUD_upgrade['info'] .
                " Upgrade Applied Successfully!</font><br />";
        }
    }

    $database->setQuery("UPDATE `#__unocloud_config` SET UNOCLOUD_value='2.0.2' WHERE UNOCLOUD_key='UNOCLOUD_version'");
    $database->query();
}
?>

</table>